package service.impl;

import dao.UserDao;
import dao.impl.UserDaoImpl;
import entity.User;
import service.UserService;
import util.StrUtils;

import java.sql.SQLException;

/**
 * User: key
 * ClassName:UserServiceImpl
 * Date: 2023/5/5
 * Time: 18:51
 * description:
 */
public class UserServiceImpl implements UserService {
    private UserDao ud = new UserDaoImpl();
    @Override
    public User doLogin(String name, String password) {
        try {
            if(StrUtils.isNotEmpty(name)&&StrUtils.isNotEmpty(password)){
                User user = ud.findUserByUsername(name);
                if(user != null && user.getPassword().equals(password)){
                    return user;
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
